package com.nexfra.bbssys.adm.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nexfra.bbssys.adm.dao.AdmBoardMngrDao;
import com.nexfra.bbssys.common.domain.User;
  
@Service
public class AdmBoardMngrService {
	private static final Logger logger = LoggerFactory.getLogger(AdmBoardMngrService.class);
	
	@Autowired
	private AdmBoardMngrDao dao;

	/**
	 * 게시판목록을 조회한다. 
	 * @return List<Map<String,Object>>
	 */
	public List<Map<String,Object>> selectBoardList(HashMap<String, String> sqlParams) 
			throws Exception {
		return dao.selectBoardList(sqlParams);
	}
	
	/**
	 * 게시판을 조회한다. 
	 * @return Map<String,Object>
	 */
	public Map<String,Object> selectBoardOne(HashMap<String, String> sqlParams) 
			throws Exception {
		return dao.selectBoardOne(sqlParams);
	}
	
	/**
	 * 게시판을 등록한다. 
	 * @return void
	 */ 
	@Transactional(rollbackFor = Exception.class)  
	public void registBoard(HashMap<String, String> sqlParams, User user) 
			throws Exception {
		String bbsId = dao.selectSeqBBSId(sqlParams); // bbs_id 채번
		sqlParams.put("bbs_id", bbsId);
		
		// bbs마스터 등록
		dao.insertBBSMaster(sqlParams);
	}		
	
	/**
	 * 게시판을 수정한다. 
	 * @return void
	 */ 
	@Transactional(rollbackFor = Exception.class)  
	public void updateBoard(HashMap<String, String> sqlParams, User user) 
			throws Exception {
		// bbs마스터 등록
		dao.updateBBSMaster(sqlParams);
	}		
	
	/**
	 * 게시판을 삭제한다. 
	 * @return void
	 */ 
	@Transactional(rollbackFor = Exception.class)  
	public void deleteBoard(HashMap<String, String> sqlParams, User user) 
			throws Exception {
		// bbs마스터 등록
		dao.deleteBBSMaster(sqlParams);
	}		
}
